home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mgr / sparcmgr / src.zoo / src / intersect.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-17  |  2.4 KB  |  97 lines

  1. /*                        Copyright (c) 1987 Bellcore
  2.  *                            All Rights Reserved
  3.  *       Permission is granted to copy or use this program, EXCEPT that it
  4.  *       may not be sold for profit, the copyright notice must be reproduced
  5.  *       on copies, and credit should be given to Bellcore where it is due.
  6.  *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  7.  */
  8. /*    $Header: intersect.c,v 1.1 89/03/17 08:21:14 sau Exp $
  9.     $Source: /m1/mgr.new/src/RCS/intersect.c,v $
  10. */
  11. static char    RCSid_[] = "$Source: /m1/mgr.new/src/RCS/intersect.c,v $$Revision: 1.1 $";
  12.  
  13. /*
  14.  *******************************************************************************
  15.  *
  16.  *    see if two windows intersect
  17.  */
  18.  
  19. #include "bitmap.h"
  20. #include <stdio.h>
  21. #include "defs.h"
  22.  
  23. #define WIDE(w)    w->BIT_WIDE(border)
  24. #define HIGH(w)    w->BIT_HIGH(border)
  25.  
  26. intersect(win1,win2)
  27. register WINDOW *win1, *win2;
  28. {
  29.     int result;
  30.     result = (
  31.         win1->x0 + WIDE(win1) < win2->x0 ||
  32.         win2->x0 + WIDE(win2) < win1->x0 ||
  33.         win1->y0 + HIGH(win1) < win2->y0 ||
  34.         win2->y0 + HIGH(win2) < win1->y0
  35.         ?0:1); 
  36.         return(result);
  37. }
  38.  
  39. /*
  40.  *******************************************************************************
  41.  *
  42.  *    see if any window intersects any other
  43.  */
  44.  
  45. int
  46. alone(check)
  47. register WINDOW *check;
  48. {
  49.     register WINDOW *win;
  50.         for(win=active;win != (WINDOW *) 0;win=win->next)
  51.           if (check!=win && intersect(check,win))
  52.              return(0);
  53.         return(1);
  54. }
  55.  
  56. /***********************************************************************
  57.  *    see if mouse is in window 
  58.  */
  59.  
  60. mousein(x,y,win,how)
  61. register int x,y;
  62. register WINDOW *win;
  63. int how;        /* how:  0-> intersect   1-> point */
  64. {
  65.    if (how == 0)
  66.     return(
  67.         x+16 < W(x0) || x > W(x0) + WIDE(win) ||
  68.             y+16 < W(y0) || y > W(y0) + HIGH(win)
  69.             ?0:1);
  70.    else
  71.     return(
  72.         x < W(x0) || x > W(x0) + WIDE(win) ||
  73.             y < W(y0) || y > W(y0) + HIGH(win)
  74.             ?0:1);
  75. }
  76.  
  77. /**********************************************************************
  78.  *      see if mouse is in text region
  79.  */
  80.  
  81. int
  82. in_text(x,y,win)
  83. register int x,y;
  84. register WINDOW *win;
  85.    {
  86.    if (W(text.wide)) {
  87.       int x0 = W(x0)+W(text.x);
  88.       int y0 = W(y0)+W(text.y);
  89.       return(
  90.         x < x0 || x > x0 + W(text.wide) ||
  91.             y < y0 || y > y0 + W(text.high)
  92.             ?0:1);
  93.       }
  94.    else
  95.       return(mousein(x,y,win,1));
  96.    }
  97.